import { createRouter, createWebHistory,RouteRecordRaw  } from 'vue-router'
import Layout from '@/layout/index.vue'

export const routes  = [
    {
        path: '/login',
        component: () => import('@/views/login/index.vue'),
        hidden: true
    },
    {
        path: '/',
        component: Layout,
        redirect: '/home',
        children: [
            {
                path: 'home',
                name: 'home',
                component: () => import('@/views/home/index.vue'),
                meta: {
                    title: '首页',icon: "HomeFilled", affix: true, noCache: true
                }
            }
        ],
    },
    {
        path: '/redirect',
        component: Layout,
        hidden: true,
        children: [
            {
                path: '/redirect/:path(.*)',
                meta: { title: '首页' },
                component: () => import('@/views/redirect/index.vue')
            }
        ]
    },
    {
        path: "/system",
        name: "system",
        meta: { title: "系统管理", icon: "Tools", hidden: false },
        component: Layout,
        children: [
           
            {
                path: "users",
                name: "users",
                meta: { title: "用户管理", icon: "", hidden: false, noCache: false },
                component: () => import('@/views/system/users.vue'),
                children: []
            },
            {
                path: "roles",
                name: "roles",
                meta: { title: "角色管理", icon: "", hidden: false, noCache: false },
                component: () => import('@/views/system/roles.vue'),
                children: []
            },
            {
                path: "menus",
                name: "menus",
                meta: { title: "菜单管理", icon: "", hidden: false, noCache: false },
                component: () => import('@/views/system/menus.vue'),
                children: []
            },
            {
                path: "tableCheckTest",
                name: "tableCheckTest",
                meta: { title: "表格验证", icon: "", hidden: false, noCache: false },
                component: () => import('@/views/system/tableCheckTest.vue'),
                children: []
            },
        ]
    },
    {
        ////system/users
        path: "/goods",
        name: "goods",
        meta: { title: "商品", icon: "Tools", hidden: false },
        component: Layout,
        children: [
            {
                path: "goodsClassify",
                name: "goodsClassify",
                meta: { title: "商品分类", icon: "", hidden: false, noCache: false },
                component: () => import('@/views/goods/goodsClassify.vue'),
                children: []
            },
            {
                path: "goodsRule",
                name: "goodsRule",
                meta: { title: "商品规格", icon: "", hidden: false, noCache: false },
                component: () => import('@/views/goods/goodsRule.vue'),
                children: []
            },
            {
                path: "manage",
                name: "manage",
                meta: { title: "商品管理", icon: "", hidden: false, noCache: false },
                component: () => import('@/views/goods/goodsManage.vue'),
                children: []
            },
            {
                path: "goodsEdit",
                name: "goodsEdit",
                hidden:true,
                meta: { title: "新增商品", icon: "", hidden: false, noCache: false },
                component: () => import('@/views/goods/goodsEdit.vue'),
                children: []
            },
            {
                path: "material",
                name: "material",
                meta: { title: "素材管理", icon: "", hidden: false, noCache: false },
                component: () => import('@/views/goods/material.vue'),
                children: []
            },
            
        ]
    },
    {
        ////system/users
        path: "/user",
        name: "user",
        meta: { title: "用户", icon: "Tools", hidden: false },
        component: Layout,
        children: [
            {
                path: "userinfo",
                name: "userinfo",
                meta: { title: "用户管理", icon: "", hidden: false, noCache: false },
                component: () => import('@/views/user/userinfo.vue'),
                children: []
            }

        ]
    },
    {
        ////system/users
        path: "/marketing",
        name: "marketing",
        meta: { title: "营销", icon: "Tools", hidden: false },
        component: Layout,
        children: [
            {
                path: "couponinfo",
                name: "couponinfo",
                meta: { title: "优惠卷", icon: "", hidden: false, noCache: false },
                component: () => import('@/views/marketing/couponinfo.vue'),
                children: []
            },
            {
                path: "addcoupon",
                name: "addcoupon",
                meta: { title: "添加优惠卷", icon: "", hidden: false, noCache: false, keepAlive: false },
                component: () => import('@/views/marketing/addcoupon.vue'),
                children: []
            },
        ]
    },
    {
        ////system/users
        path: "/order",
        name: "order",
        meta: { title: "订单", icon: "Tools", hidden: false },
        component: Layout,
        children: [
            {
                path: "orderInfo",
                name: "orderInfo",
                meta: { title: "订单", icon: "", hidden: false, noCache: false },
                component: () => import('@/views/order/order.vue'),
                children: []
            }

        ]
    },
]

const router = createRouter({
    history: createWebHistory(),
    routes: routes,
    scrollBehavior(to, from, savedPosition) {
        if (savedPosition) {
            return savedPosition
        } else {
            return { top: 0 }
        }
    },
})
// router.beforeEach( (to, from, next) => {
// 	console.log(to);
// })
export default router

